knitr::opts_chunk$set(fig.pos = 'H') # invalidate cache when the tufte version changes memory.limit(size=100000) library(tidyverse, quietly=TRUE) library(scales, quietly=TRUE) library(codemogAPI, quietly=TRUE) library(codemogProfile, quietly=TRUE) library(knitr, quietly=TRUE) library(kableExtra, quietly=TRUE) library(RPostgreSQL, quietly=TRUE) library(rmarkdown) library(tinytex) library(VennDiagram) library(gridExtra) library(coProfileDashboard) #text Functions baseText<- function(place){ outTest <- paste0("Information for ",place," is compiled by the State Demography Office and the U.S. Bureau of the Census (NEED TEXT)") return(outTest) } # Creating the conditional display vars #Basic Stats if("stats" %in% params$outChk) { outStats <- TRUE } else { outStats <- FALSE } #Population Forecast if("popf" %in% params$outChk) { outPopf <- TRUE } else { outPopf <- FALSE } #Population Characteristics: Age if("pop" %in% params$outChk) { outPop <- TRUE } else { outPop <- FALSE } #Population Characteristics: Income, Education and Race if("popc" %in% params$outChk) { outPopC <- TRUE } else { outPopC <- FALSE } #Housing if("housing" %in% params$outChk) { outHouse <- TRUE } else { outHouse <- FALSE } #Commuting if("comm" %in% params$outChk) { outComm <- TRUE } else { outComm <- FALSE } #Employment by Industry if("emplind" %in% params$outChk) { outEmply <- TRUE } else { outEmply <- FALSE } #Employment and Demographic Forecast if("emply" %in% params$outChk) { outEmplind <- TRUE } else { outEmplind <- FALSE } oYr <- params$curYr oACS <- params$curACS placeName <- params$ctyName fips5 <- params$fips fips3 <- substr(params$fips,3,5) fipsN <- as.numeric(fips3)
r placeName
r if(outStats) '## Basic Statistics'
\bminione
if(outStats) { cat(baseText(placeName)) #`r colFmt(paste0(placeName," Demographic and Economic Profile"),"dolagreen")` }
\emini \bminitwo
if(outStats){ y <- cp_countymap(substr(fips5,3,5)) print(y) }
\emini \FloatBarrier
if(outStats){ x <- statsTable1(cty=fips5, place="", sYr=2010, eYr= oYr, ACS=oACS, oType="latex") print(x) }
\newpage
r if(outPopf) '## Population Forecasts'
#Population, Migration and Natural Increase if(outPopf){ # Population Change Table popTab <- popTable(cty=fips3,ctyname=placeName,sYr=1990,eYr=oYr,oType="latex") cat(popTab$text) print(popTab$table) }
#County forecast if(outPopf) { popf1 <- county_timeseries(fips=fips3,endYear=oYr) popf2 <- popForecast(fips=fipsN, ctyname = placeName) popf3 <- cocPlot(fips=fipsN,ctyname=placeName,lYr=oYr) print(popf1$plot) print(popf2$plot) print(popf3$plot) }
\newpage
r if(outPop) '## Population by Age'
r if(outPop) "Age Text (NEED TEXT)"
#Population, Migration and Natural Increase if(outPop){ # Age Plot popa1 <- agePlotPRO(fips=fipsN, ctyname=placeName, yrs=2016) print(popa1$plot) }
#Population, Migration and Natural Increase if(outPop){ popa3 <- ageForecastPRO(fips=fipsN,stYr=2010,mYr=2015,eYr=2025) print(popa3$plot) }
#Population, Migration and Natural Increase if(outPop){ medAge <- medianAgeTab(fips=fips3, ACS=oACS, ctyname=placeName,oType ="latex") print(medAge) }
#Population, Migration and Natural Increase if(outPop){ # Age Plot popa4 <- migbyagePRO(fips=fipsN, ctyname = placeName) print(popa4$plot) }
\newpage
r if(outPopC) '## Population Characteristics: Income, Education and Race'
r if(outPopC) 'Population Characteristics: Income, Education and Race Text (NEED TEXT)'
if(outPopC){ # Population Chatacteristics popc1 <- incomePRO(fips=fips3,ctyname=placeName, ACS=oACS) print(popc1$plot) }
if(outPopC){ popc2 <- educPRO(fips=fips3, ctyname=placeName, ACS=oACS) print(popc2$plot) }
\FloatBarrier
if(outPopC){ race1 <- raceTab1(fips=fips3,ctyname=placeName,ACS=oACS,oType="latex") print(race1) }
if(outPopC){ race2 <- raceTab2(fips=fips3,ctyname=placeName,ACS=oACS,oType="latex") print(race2) }
\newpage
r if(outHouse) '## Housing and Households'
r if(outHouse) 'Housing Text (NEED TEXT)'
if(outHouse){ # Housing poph1 <<- houseEstPRO(fips=fips3,ctyname=placeName,curYr=oYr) print(poph1$plot) }
if(outHouse){ hTab <- housePRO(fips=fips3, ctyname=placeName, ACS=oACS, oType="latex") print(hTab) }
if(outHouse){ OOTab <- OOHouse(fips=fips3,ctyname=placeName,ACS=oACS, oType="latex") print(OOTab) }
if(outHouse){ RTTab <- RTHouse(fips=fips3,ctyname=placeName,ACS=oACS, oType="latex") print(RTTab) }
\newpage
r if(outComm) '## Commuting'
\bminione
if(outComm){ cat("Commuting Text (NEED TEXT)") }
\emini \bminitwo
if(outComm){ # Commuting popt1 <<- GenerateVenn(fips=fips3,ctyname=placeName,oType="latex") grid.arrange(popt1$plot) }
\emini
\FloatBarrier
if(outComm){ print(popt1$workTab) }
if(outComm){ print(popt1$liveTab) }
if(outComm){ popt2 <<- jobMigration(fips=fips3,ctyname=placeName,maxyr = oYr) print(popt2$plot) }
\newpage
r if(outEmply) '## Employment by Industry'
r if(outEmply) 'Employment by Industry text (NEED TEXT)'
if(outEmply) { popei1 <<- coProfileDashboard::ms_jobs(fips=fips3,ctyname=placeName, maxyr = oYr) print(popei1$plot) }
if(outEmply) { popei2 <<- jobsByIndustry(fips=fips3,ctyname=placeName, curyr = oYr) print(popei2$plot) }
if(outEmply) { popei3 <<- baseIndustries(fips=fips3,ctyname=placeName, curyr = oYr, oType="latex") print(popei3$plot) }
if(outEmply) { print(popei3$table) }
\newpage
r if(outEmplind) '## Employment and Demographic Forecast'
r if(outEmplind) 'Employment and Demographic Forecast text (NEED TEXT)'
if(outEmplind) { #Employment and Demographic Forecast Materials popem1 <<- jobsPopForecast(fips=fips3,ctyname=placeName) print(popem1$plot) }
if(outEmplind) { popem2 <<- weeklyWages(fips=fips3,ctyname=placeName) print(popem2$plot) }
if(outEmplind) { popem3 <<- residentialLF(fips=fips3,ctyname=placeName) print(popem3$plot1) }
if(outEmplind) { print(popem3$plot2) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.